package com.lixin.smartclassroom.ui.home.tab2.activity

import androidx.fragment.app.Fragment
import com.lixin.smartclassroom.databinding.ActivityCourseReviewBinding
import com.lixin.smartclassroom.ui.home.adapter.PagerAdapter
import com.lixin.smartclassroom.ui.home.tab1.fragment.ClassDetailChildFra
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.addIntArgument
import com.lixinkeji.extension.addStringArgument
import com.lixinkeji.extension.getIntentString

/**
 * Description 课程批阅
 * Author: lwc
 * Date:2023/12/9 16:14
 */
class CourseReviewAct : BaseActivity<ActivityCourseReviewBinding>() {
    override fun getViewBinding() = ActivityCourseReviewBinding.inflate(layoutInflater)

    override fun topBarHide() = false
    override fun startPadding() = true
    override fun title() = "课程批阅"
    private var courseid = ""
    private var classid = ""


    override fun iniView() {
        courseid = getIntentString("courseid")
        classid = getIntentString("classid")
        initSlidingLayout()
    }

    private fun initSlidingLayout() {
        if(courseid.isNotEmpty()){
            val titles = ArrayList<String>()
            val fragments = ArrayList<Fragment>()
            titles.add("待批阅")
            titles.add("已批阅")
            fragments.add(ClassDetailChildFra().addIntArgument("type", 6).addStringArgument("courseid",courseid))
            fragments.add(ClassDetailChildFra().addIntArgument("type", 10).addStringArgument("courseid",courseid))
            var mPageAdapter = PagerAdapter(supportFragmentManager, fragments, titles)

            binding.apply {
                viewPager.adapter = mPageAdapter
                tabLayout.setViewPager(viewPager)
            }
        }else if(classid.isNotEmpty()){
            val titles = ArrayList<String>()
            val fragments = ArrayList<Fragment>()
            titles.add("待批阅")
            titles.add("已批阅")
            fragments.add(ClassDetailChildFra().addIntArgument("type", 11).addStringArgument("classid",classid))
            fragments.add(ClassDetailChildFra().addIntArgument("type", 12).addStringArgument("classid",classid))
            var mPageAdapter = PagerAdapter(supportFragmentManager, fragments, titles)

            binding.apply {
                viewPager.adapter = mPageAdapter
                tabLayout.setViewPager(viewPager)
            }
        }

    }

}